﻿<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link type="text/css" rel="stylesheet" href="css/style.css" />
<link type="text/css" rel="stylesheet" href="css/layout.css" />
<title>Danh sách đơn đặt hàng</title>

</head>

<body>
<?php include("menu.php"); 
include("session.php");
include("../include/config.php");
?>

<div id="head-noidung">
		<div id="head-main">
    <a href = "contract.php?del_ht=ok" style = "float:right;color:blue;text-decoration:none;" onMouseOver="this.style.color='#0F0'" onMouseOut ="this.style.color='blue'" onclick="return confirm('Ban muon xoa Danh Sach Da Hoan Thanh?');" href="?del_ht=ok" >Bỏ những đơn đặt hàng đã hoàn thành</a> 
	<a style = "float:right;padding-right:5px;padding-top:3px;"><img src="images/no.png" width="15" height="15"/> </a>
	<p>Danh sách đơn đặt hàng </p>
	<table class="classtable">
	<thead>
		<tr>
			<th>STT</th>
			<th>Tên Khách Hàng</th>
			<th>Điện thoại</th>
			<th>Email</th>
			<th>Tổng Giá</th>
			<th>Ngày giao</th>
			<th>Tình Trạng</th>
			<th>Thao tác</th>
		</tr>
	</thead>
	<?php 
	$sql1="SELECT * FROM contract ORDER By id DESC";
	$sql_1 = "UPDATE contract SET status = 1 WHERE id =";
	$sql_2 = "UPDATE contract SET status = 0 WHERE id =";
	$rs1=mysql_query($sql1);
	if($rs1) {
	 $i=1;
	 
	 while($rw1=mysql_fetch_array($rs1)) {	
	 
	?>
	<tbody>
	<tr>
		
		<td><?php echo $i?></td>
		<td><?php echo $rw1["customer_name"];?></td>
		<td><?php echo $rw1["phone"];?></td>
		<td><?php echo $rw1["email"];?></td>
		<td><?php echo $rw1["price"];?></td>
		<td><?php echo $rw1["deliver_date"];?></td>
		<td><?php if($rw1["status"]==1) { ?> <img src="images/yes.png" width="23" height="22"/><?php } else { ?> <img src="images/no.png" width="23" height="22"/> <?php } ?></td>		
		<td><a href = "contract.php?act=act1&id=<?php echo $rw1["id"]; ?>"> Hoàn Thành </a><a>|</a> <a href = "contract.php?act=act2&id=<?php echo $rw1["id"]; ?>">Chưa</a>								
	</tr>
	<?php 
	$i+=1;
	}
	} ?>		

		
</tbody>

</table>
<?php
if(isset($_REQUEST["del_ht"]) && $_REQUEST["del_ht"] == "ok")
{
			  $sqldel="DELETE FROM contract WHERE status = 1";
			  mysql_query($sqldel);
			  header("Location:contract.php"); 
}
if(isset($_REQUEST["act"]) && isset($_REQUEST["id"]))
{
 $id_edit = $_REQUEST["id"];
 if($_REQUEST["act"] == "act1"){             
              $sqldel="UPDATE contract SET status = 1 WHERE id=$id_edit";
			  mysql_query($sqldel);
			  header("Location: contract.php");
			}
 else {
              $sqldel="UPDATE contract SET status = 0 WHERE id=$id_edit";
			  mysql_query($sqldel);
			  header("Location: contract.php");
	}
}			
?>		
	</div>	
</div>

<?php include("images/cherry/footer.php"); ?>

</body>
</html>